<?php
/*
Copyright (C) 2009 de Flotte Maxence

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
?>
<?php


/**
 * Déclaration du domaine Article
 */
class DomLabel {
	
	public $id;
	public $name;
	public $dateC;
	public $dateU;
	public $user;
	public $group;
	
	public $userR;
	public $userW;
	public $groupR;
	public $groupW;
	public $otherR;
	public $otherW;
	
	public $type;
	

	private $onCommit = false;
	private $afterCommit = false;
	
	protected $tr;
	protected $trDom;
	
	function __construct() {
		$this->tr = new ZzTranslation('dom_errors');
		$this->trDom = new ZzTranslation('dom_zlog');
		
		$this->id = new DomTypeLabel('id',$this->trDom->tr('identifiant'),'label');
		$this->id->setPrimary();
		$this->name = new DomTypeString('name',$this->trDom->tr('nom'),'label');
		$this->name->setNotNullable();
		$this->dateC = new DomTypeLabelDate('dateC',$this->trDom->tr('date de création'),'label');
		$this->dateU = new DomTypeLabelDate('dateU', $this->trDom->tr('date de modification'),'label');
		$this->user = new DomTypeLabelUser('user', $this->trDom->tr('utilisateur'),'label');
		$this->group = new DomTypeLabelGroup('group', $this->trDom->tr('groupe'),'label');
		
		$this->userR = new DomTypeBool('userR','','label');
		$this->userW = new DomTypeBool('userW','','label');;
		$this->groupR = new DomTypeBool('groupR','','label');;
		$this->groupW = new DomTypeBool('groupW','','label');;
		$this->otherR = new DomTypeBool('otherR','','label');;
		$this->otherW = new DomTypeBool('otherW','','label');;
		
		$this->type = new DomTypeString('type', $this->trDom->tr('type'),'label');
		$this->type->setNotNullable();
		//$this->chmod = new DomTypeLabel('chmod',$this->trDom->tr('chmod'),'label');
	}
	/**
	 * Est executé à l'enregistrement
	 */
	public function onCommit($zzio) {
		if($this->onCommit)
			return false;
		$this->onCommit = true;
		return true;
	}
	/**
	 * Est executé après l'enregistrement
	 */
	public function afterCommit($zzio) {
		if($this->afterCommit)
			return false;
		$this->afterCommit = true;
		return true;
	}
	
	protected function addJS() {
		$GLOBALS['js'][strtolower(get_class($this))] = true;
	}
}

?>